`ifndef TRANSACTION_SVH
`define TRANSACTION_SVH

class trans_a; // 基类
	bit [3:0] a;

	function new(input bit [3:0] a = 0);
		this.a = a;
		$display("create a trans_a object");
	endfunction

	virtual function void print(input string name = ""); // 虚方法
		$display("%s: based class, a=%0d", name, a);
	endfunction
endclass

class trans_b extends trans_a; // 派生类
	bit [3:0] b; // 新属性b

	function new(input bit [3:0] a = 0, input bit [3:0] b = 0);
		super.new(a); // 默认执行super.new()
		this.b = b;
		$display("create a trans_b object");
	endfunction

	function void print(input string name = ""); // 重定义基类的虚方法
		super.print(name); // 调用基类的print
		$display("%s: derived class, b=%0d", name, b);
	endfunction
endclass

`endif
